module.exports = {
  dataKey: {
    // qrcodeData: 'qrcodeData',
    // session_key: 'session_key',
    // userInfo: 'userInfo',
    // token: 'token',
    // uid: 'uid',
    // recordList: 'recordList',
    // recommendData: 'recommendData',
    // liveData: 'liveData',
    // tip_banner: 'tip_banner',
    // wx_no: 'wx_no',
    // is_host: 'is_host',
    // step_num: 'step_num',
    // login_time: 'login_time'
  },
  setData: (key, data) => {
    return new Promise((resolve, reject) => {
      uni.setStorage({
        key,
        data,
        success: resolve,
        fail: reject
      });
    });
  },
  getData: key => {
    return new Promise((resolve, reject) => {
      uni.getStorage({
        key,
        success: res => {
          if (res.errMsg === 'getStorage:ok') {
            resolve(res.data);
          } else {
            reject(res.errMsg);
          }
        },
        fail: reject
      });
    });
  },
  removeData: key => {
    return new Promise(resolve => {
      uni.removeStorage({
        key,
        success: resolve,
        fail: resolve
      });
    });
  },
  clearData: () => {
    return new Promise((resolve, reject) => {
      uni.clearStorage();
      resolve();
    });
  }
};